//
//  GLWaterFlowView.h
//  GLWaterFlowView
//
//  Created by CoderGL on 15/11/27.
//  Copyright © 2015年 GL. All rights reserved.
//

#import <UIKit/UIKit.h>

@class GLWaterFlowView, GLWaterFlowViewCell;


typedef NS_ENUM(NSInteger, GLWaterFlowViewType) {
    GLWaterFlowViewTypeTop = 0,
    GLWaterFlowViewTypeBottom,
    GLWaterFlowViewTypeLeft,
    GLWaterFlowViewTypeRight,
    
    GLWaterFlowViewTypeColumn, // 列间距
    GLWaterFlowViewTypeRow // 行间距
};

#pragma mark - 数据源
@protocol GLWaterFlowViewDataSoruce <NSObject>
@required
/**
 *  一共有多少个cell
 */
- (NSUInteger)numberOfCellsInWaterFlowView:(GLWaterFlowView *)waterFlowView;

/**
 *  返回index位置对应的cell
 *  @param index  索引位置
 */
- (GLWaterFlowViewCell *)waterFlowView:(GLWaterFlowView *)waterFlowView cellAtIndex:(NSUInteger)index;

@optional
/**
 *  一共返回多少列
 */
- (NSUInteger)numberOfColumnInWaterFlowView:(GLWaterFlowView *)waterFlowView;

@end


#pragma mark - 代理
@protocol GLWaterFlowViewDelegate <UIScrollViewDelegate>
@optional
/**
 *  返回index对应cell的高度
 */
- (CGFloat)waterFlowView:(GLWaterFlowView *)waterFlowView heightAtIndex:(NSUInteger)index;

/**
 *  选中index对应的cell时掉用
 *
 */
- (void)waterFlowView:(GLWaterFlowView *)waterFlowView didSelectAtIndex:(NSUInteger)index;


- (CGFloat)waterFlowView:(GLWaterFlowView *)waterFlowView waterFlowViewType:(GLWaterFlowViewType)type;

@end


@interface GLWaterFlowView : UIScrollView
@property (nonatomic, weak) id <GLWaterFlowViewDataSoruce> dataSource;
@property (nonatomic, weak) id <GLWaterFlowViewDelegate> delegate;

/**
 *  刷新数据
 */
- (void)reloadData;

/**
 *  根据标识来从缓存池获取可循环利用的cell
 */
- (GLWaterFlowViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier;

/**
 *  cell的宽度
 */
- (CGFloat)cellWidth;

@end


